<template>
  <div class="layout">
    <div class="helpAppealDetail">
      <div
        style="display: flex; justify-content: space-between; margin: 20px 0 30px 0"
      >
        <Breadcrumb class="breadcrumb" :crumbs="crumbs"></Breadcrumb>
      </div>
      <ContainerTitle text="求职诉求简介" :more="false"></ContainerTitle>
      <!-- <div class="title">求职诉求简介</div> -->
      <div class="tableDiv" v-loading="loading">
        <div class="rowDiv">
          <div style="width: 50%; display: flex; justify-content: left">
            <div class="keyDiv">姓名</div>
            <div class="valueDiv">{{ appeal.name }}</div>
          </div>
          <div style="width: 50%; display: flex; justify-content: left">
            <div class="keyDiv">年龄</div>
            <div class="valueDiv">{{ $getAgeByBirth(appeal.birthMonthFmt) }}</div>
          </div>
        </div>
        <div class="rowDiv">
          <div style="width: 50%; display: flex; justify-content: left">
            <div class="keyDiv">性别</div>
            <div class="valueDiv" v-if="(genderLsit && genderLsit.length>0) && appeal.gender">
              {{ $selectDict(genderLsit,appeal.gender).dictLabel }}
            </div>
          </div>
          <div style="width: 50%; display: flex; justify-content: left">
            <div class="keyDiv">学历</div>
            <div class="valueDiv" v-if="(workerEducationLsit && workerEducationLsit.length>0) && appeal.education">
              {{ $selectDict(workerEducationLsit,appeal.education).dictLabel }}
            </div>
          </div>
        </div>
        <div class="rowDiv">
          <div style="width: 50%; display: flex; justify-content: left">
            <div class="keyDiv">需求岗位</div>
            <div class="valueDiv">{{ appeal.post }}</div>
          </div>
          <div style="width: 50%; display: flex; justify-content: left">
            <div class="keyDiv">期望薪资</div>
            <div class="valueDiv">{{ appeal.expectSalary }}元</div>
          </div>
        </div>
        <div class="rowDiv">
          <div style="display: flex; justify-content: left">
            <div class="keyDiv">职业技能</div>
            <div class="valueDivFull">{{ appeal.skill }}</div>
          </div>
        </div>
        <!-- <div class="rowDiv">
          <div style="display: flex; justify-content: left">
            <div class="keyDiv">过往经验</div>
            <div class="valueDivFull">{{ appeal.skill }}</div>
          </div>
        </div> -->
      </div>
      <template v-if="appeal.status ==2">
        <div class="title">工作经验</div>
        <div v-if="experience.length > 0" v-loading="loading">
          <div class="tableDiv" v-for="(experience, index) in experience" :key="index">
              <div class="rowDiv">
                  <div style="width: 50%; display: flex; justify-content: left">
                      <div class="keyDiv">公司名称</div>
                      <div class="valueDiv">{{ experience.companyName }}</div>
                  </div>
                  <div style="width: 50%; display: flex; justify-content: left">
                      <div class="keyDiv">工作时间</div>
                      <div class="valueDiv" v-if="experience.beginDate"> {{ new Date( experience.beginDate).pattern("yyyy-MM-dd") }} 至 {{ new Date( experience.endDate).pattern("yyyy-MM-dd") }} </div>
                      <div class="valueDiv" v-else>无</div>
                  </div>
              </div>
              <div class="rowDiv">
                  <div style="width: 50%; display: flex; justify-content: left">
                      <div class="keyDiv">部门</div>
                      <div class="valueDiv">{{ experience.dept }}</div>
                  </div>
                  <div style="width: 50%; display: flex; justify-content: left">
                      <div class="keyDiv">职位</div>
                      <div class="valueDiv">{{ experience.post }}</div>
                  </div>
              </div>
              <div class="rowDiv">
                  <div style="display: flex; justify-content: left">
                      <div class="keyDiv">工作内容</div>
                      <div class="valueDivFull">{{ experience.workContent }}</div>
                  </div>
              </div>
          </div>
        </div>
        <div v-else>暂无工作经验数据</div>
      </template>
      
      <!-- <div class="title">劳务帮扶原因</div>
      <div class="tableDiv">
        <div class="rowDiv">
          <div style="width: 100%; display: flex; justify-content: left">
            <div class="keyDiv" style="width: 110px">劳务帮扶时间期限</div>
            <div class="valueDiv" style="width: 798px">
              {{ appeal.beginDate + " 至 " + appeal.endDate }}
            </div>
          </div>
        </div>
        <div class="rowDiv">
          <div style="width: 100%; display: flex; justify-content: left">
            <div class="keyDiv" style="width: 110px">劳务帮扶申请原因</div>
            <div class="valueDiv" style="width: 798px">{{ appeal.reason }}</div>
          </div>
        </div>
      </div> -->
      <!-- <div class="title">岗位需求</div>
      <div class="tableDiv" style="margin-bottom: 50px">
        <div class="rowDiv">
          <div style="width: 50%; display: flex; justify-content: left">
            <div class="keyDiv">就业需求</div>
            <div class="valueDiv">{{ appeal.post }}</div>
          </div>
          <div style="width: 50%; display: flex; justify-content: left">
            <div class="keyDiv">期望薪资</div>
            <div class="valueDiv">{{ appeal.expectSalary + "元" }}</div>
          </div>
        </div>
      </div> -->
      <Buttons @goBack="goBack()" @none="''" @apply="apply" :buttons="buttons"></Buttons>
    </div>
  </div>
</template>

<script>
import Breadcrumb from "@/components/breadcrumb";
// api
import config from "@/utils/config.js";
import { request,uploadFile } from "../../utils/request";
import {checkLogin,relogin} from '@/utils/util.js'
import { getHelpAppealDetail } from '@/common/api/help'

export default {
  name: "helpAppealDetail",
  meta: {
    name: "求职诉求简介情页",
  },
  components: { Breadcrumb },
  data() {
    return {
      crumbs: [
        {label: "人才服务",value: "help",},
        {label: "求职诉求列表",value: "helpAppealList",},
        {label: "求职诉求简介",value: "",choose: true,},
      ],
      appeal: {},
      loading: false,
      genderLsit: [],
      experience: [],  // 工作经验
      workerEducationLsit: []
    };
  },
  inject: ['showModal'],
  computed:{
    buttons(){
      let btnStyle = [{text:"返回",type:"normal",size:"l",method:"goBack"}]
      if(this.appeal.status == 2){
        btnStyle.push({text:"已通过",type:"success",size:"l",method:"none"})
      }else if(this.appeal.status == 3){
        btnStyle.push({text:"已拒绝",type:"success",size:"l",method:"none"})
      }else if(this.appeal.status == 1){
        btnStyle.push({text:"已申请过",type:"success",size:"l",method:"none"})
      }else if(this.appeal.status == 0){
        btnStyle.push({text:"申请简历",type:"success",size:"l",method:"apply"})
      }
      return btnStyle;
    }
  },
  mounted(){
    this.loading = true;
    this.getHelpAppealDetail();
    this.gettypeList()
  },
  // activated() {

  // },
  methods: {
    // 字典查询 
    async gettypeList() {
      let api = `gender,worker_education`;
      // 调用公共方法中的查询字典表
      this.getDictList(this, api).then((res) => {
        this.genderLsit = res.gender;
        this.workerEducationLsit = res.worker_education;
      });
    },
    apply(){
      if(checkLogin(this)){
        let formData = new FormData();
        formData.append("id", this.appeal.workerId);
        uploadFile(this, config.api.workerApply, formData).then((res) => {
          if (res.code != "200") return this.$message.warning(res.msg);
          this.showModal('申请简历成功，请耐心等待！', require('@/assets/image/success.png'))
          this.appeal.status = 1
        });
      } else {
        relogin(this);
      }
      
    },
    // 获取帮扶案例详情
    async getHelpAppealDetail() {
      // let { code, data, msg } = await request(
      //   this,
      //   config.api.laborDemandDetail + this.$route.query.id
      // );
      let {code, data, msg} = await getHelpAppealDetail(this.$route.query.id)
      console.log('200', code)
      this.loading = false;
      msg = msg || '服务器系统错误'
      if (code != 200) return this.$message.error(msg);
      this.appeal = data || {};
      this.experience = data.workerExperienceList || []
    },
    /**
     * 返回上一页
     */
    goBack() {
      this.$router.back();
      // this.$router.push({ path: 'helpAppealList' });
    },
  },
};
</script>

<style scoped>
.layout {
  min-height: 100vh;
  position: relative;
  padding-bottom: 150px;
  box-sizing: border-box;
}
.btn-bottom {
  text-align: center;
  margin: 40px 0 150px;
}
.btn-bottom .cancelBtn {
  display: inline-block;
  font-size: 14px;
  background-color: #f1f2f4;
  color: #045db9;
  /* padding: 10px 46px; */
  text-align: center;
  border-radius: 5px;
  margin-right: 10px;
  width: 120px;
  text-align: center;
  line-height: 40px;
  height: 40px;
}
.btn-bottom .cancelBtn:hover {
  cursor: pointer;
  box-shadow: 0px 0px 5px #eeeeee;
}

.footer {
  position: absolute;
  bottom: 0;
  width: 100%;
}

.helpAppealDetail {
  width: 1200px;
  margin: 0 auto;
}

.btn-bottom .sendBtn {
  /* padding: 10px 30px; */
  background-color: #045db9;
  display: inline-block;
  color: #ffffff;
  font-size: 14px;
  border-radius: 5px;
  transition: all 0.2s ease 0s;
  margin-right: 10px;
  width: 120px;
  text-align: center;
  line-height: 40px;
  height: 40px;
}
.btn-bottom .sendBtn:hover {
  box-shadow: 0px 5px 5px #e1e1e1;
  cursor: pointer;
}

.helpAppealDetail .title {
  font-size: 20px;
  font-weight: bold;
  text-align: left;
  color: #045db9;
  border-bottom: 2px solid #045db9;
  padding: 10px 10px 10px 0;
  margin-top: 30px;
  /* margin-bottom: 20px; */
  margin: 30px 0 18px 0;
}

.helpAppealDetail .tableDiv {
  border: 1px solid #eeeeee;
  color: #666666;
  margin-bottom: 20px;
}

.helpAppealDetail .tableDiv .rowDiv {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #eeeeee;
  font-size: 13px;
}

.helpAppealDetail .tableDiv .rowDiv .keyDiv {
  text-align: left;
  background-color: #f4f4f4;
  padding: 10px 20px;
  width: 100px;
  flex-shrink: 0;
}

.helpAppealDetail .tableDiv .rowDiv .valueDiv {
  text-align: left;
  padding: 10px 20px;
  width: 100%;
  word-break: break-all;
}
.helpAppealDetail .tableDiv .rowDiv .valueDivFull {
  text-align: left;
  padding: 10px 20px;
  word-break: break-all;
  flex: 1;
}
</style>
